import json
from ronglian_sms_sdk import SmsSDK
from django.conf import settings
# accId = '2c94811c9035ff9f0192316e675c65b8'
# accToken = 'b82453403bec46bb964da9104f2ea32f'
# appId = '2c94811c9035ff9f0192316e694c65bf'

def send_message(tid, mobile, datas):
    ronglianyun = settings.RONGLIANYUN

    sdk = SmsSDK(ronglianyun.get('accId'), ronglianyun.get('accToken'), ronglianyun.get('appId'))
    # tid = "1"
    # mobile = '15765089595'
    # datas = ('9823', '2')
    resp = sdk.sendMessage(tid, mobile, datas)

    # 字符串转字段，将容联云返回的json格式的字符串转换称python中的字典格式数据
    response = json.loads(resp)

    print(resp)
    # 判断端发送是否成功，返回True False
    return response.get("statusCode") == "000000"